package judesart.app.server;

import javax.inject.Inject;

import judesart.app.domain.Exhibition;
import judesart.app.repository.ExhibitionDAO;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/youtube_uploads")
public class YoutubeUploadsControler {

    @Inject
    private ExhibitionDAO exhibitionDAO;

    @RequestMapping(value = "/exhibition/{exhibitionId}", method = RequestMethod.GET)
    protected String addVideoToExhibition(@PathVariable Long exhibitionId,
            @RequestParam String id, @RequestParam String status) {

        System.out.println(" > id [" + id + "] status [" + status + "]");

        Exhibition exhibition = exhibitionDAO.findExhibitionById(exhibitionId);
        exhibition = exhibitionDAO.addVideoToExhibition(exhibition, id);

        return "redirect:/_admin";
    }

}
